package manager.logdata;

import java.util.ArrayList;

import manager.data.RawDataObject;

public class LazyPersistedLogData extends Thread {

	private static LogDataObject ldo;
	private ArrayList<RawDataObject> ml;

	public LazyPersistedLogData(ArrayList<RawDataObject> memoryLog) {
		ldo = new LogDataObject();
		this.ml=memoryLog;
	}
	
	public void run() {
		handleSynchro();
	}

	private synchronized void handleSynchro(){
		while(true){
			try {
				wait();
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
			boolean trovato=true;
			while(trovato){
				ldo.insertBlock(ml);
				int memorySize = ml.size();
				if(memorySize>0)
					trovato=true;
				else
					trovato=false;
			}
		}
	}
}
